import 'package:flutter/cupertino.dart';
import 'package:flutter2/http/api.dart';
import 'package:flutter2/http/dio_manager.dart';
import 'package:flutter2/model/person_info_entity.dart';
import 'package:flutter2/ui/add_card.dart';
import 'package:flutter2/ui/contact.dart';
import 'package:flutter2/ui/work.dart';
import 'package:get/get.dart';

import 'loan.dart';

class StepUtils {
  StepUtils._();

  static toInfoPage() {
    DioManager.http(onLoading: () async {
      PersonInfoEntity? infoEntity = await DioManager.requestAwait<PersonInfoEntity>(path: HttpApi.getInfo);
      List cards = await DioManager.requestAwait(path: HttpApi.bankCardList);
      Widget page;
      if (infoEntity?.live.isNotEmpty != true) {
        page = WorkPage();
      } else if (infoEntity?.num1.isNotEmpty != true) {
        page = ContactPage();
      } else if (cards.isEmpty) {
        page = AddCardPage(loan: true);
      } else {
        page = LoanPage();
      }
      Get.to(page);
    });
  }
}
